package com.EthanYankang;

import javax.servlet.ServletOutputStream;
import javax.servlet.WriteListener;
import java.io.IOException;

/**
 * @Author: Ethan Yankang
 * @Program: my-tomcat2
 * @Date: 2024-09-09 15:07
 **/
public class ResponseServletOutputStream extends ServletOutputStream {
    //先将响应体存起来
    private byte[] bytes=new byte[1024];
    private int pos=0;

    public int getPos() {
        return pos;
    }

    @Override
    public void write(int b) throws IOException {
        bytes[pos]=(byte)b;
        pos++;
    }

    public byte[] getBytes() {
        return bytes;
    }

    @Override
    public boolean isReady() {
        return false;
    }

    @Override
    public void setWriteListener(WriteListener writeListener) {

    }
}
